package com.aspose.cells;

import java.util.ArrayList;
import java.util.Collections;

final class zdt {
   static ArrayList a(zn var0, zbcp var1, com.aspose.cells.b.a.b.zp var2, float var3, double var4, int var6) {
      com.aspose.cells.b.a.b.a.zf var7 = var0.e();
      com.aspose.cells.b.a.b.zq var8 = var0.f();
      var0.a(var2);
      zif var9 = var1.v();
      int var10 = var1.af();
      zbo var11;
      zbo var12;
      if (var10 == 1) {
         var12 = var9.e();
         var11 = var9.E();
      } else {
         var12 = var9.g();
         var11 = var9.G();
      }

      zbcr var13 = var9.z();
      int var14 = var13.getCount();
      double var15 = var11.n() ? zbuk.e(var11.D()) : var11.D();
      double var17 = var11.n() ? zbuk.e(var11.z()) : var11.z();
      var4 = var11.n() ? zbuk.e(var4) : var4;
      double var19 = var12.n() ? zbuk.e(var12.D()) : var12.D();
      double var21 = var12.n() ? zbuk.e(var12.z()) : var12.z();
      if (var12.n()) {
         zbuk.e(var12.x());
      } else {
         var12.x();
      }

      ArrayList var25 = new ArrayList();
      double var26 = (double)var2.e() / (var21 - var19);
      double var28 = a(var13);
      int var30 = var1.ai();
      ArrayList var31 = new ArrayList();
      zjf var32 = var1.D();

      for(int var33 = 0; var33 < var6; ++var33) {
         zjd var34 = var32.b(var33);
         if (var34 != null && !var34.a()) {
            if (!var34.b() && var34.v() <= var17 && var34.v() >= var15 && var34.q() <= var21 && var34.q() >= var19) {
               double var35 = (double)((float)var26) * (var34.q() - var19);
               if (var12.p()) {
                  var35 = (double)(var2.c() + var2.e()) - var35;
               } else {
                  var35 += (double)var2.c();
               }

               double var37 = (double)var3;
               double var39 = var34.v();
               double var41 = (var39 - var4) / (var17 - var15) * (double)var2.f();
               zsp var43 = var1.y();
               com.aspose.cells.b.a.b.zo var44 = new com.aspose.cells.b.a.b.zo((float)var35, var3);
               double var45 = 0.0D;
               double var47 = 0.0D;
               float var49 = 0.0F;
               float var50 = 0.0F;
               if (var43 != null) {
                  switch(var43.g()) {
                  case 0:
                     double var51 = var43.e().size() > var33 ? var43.a(var43.e().get(var33)) : 0.0D;
                     var45 = var51;
                     var51 = var43.f().size() > var33 ? var43.a(var43.f().get(var33)) : 0.0D;
                     var47 = var51;
                     break;
                  case 1:
                     var45 = var43.c();
                     var47 = var45;
                     break;
                  case 2:
                     var45 = var43.c() * var34.q() / 100.0D;
                     var47 = -var45;
                  }

                  var49 = (float)(var45 / (var21 - var19) * (double)var2.e());
                  var50 = (float)(var47 / (var21 - var19) * (double)var2.e());
                  if (!var11.p()) {
                     var44.b(var44.e() - (float)var41);
                  } else {
                     var44.b(var44.e() + (float)var41);
                  }
               }

               var43.a(var44, var49, var50);
               zsp var57 = var1.x();
               var45 = 0.0D;
               var47 = 0.0D;
               var49 = 0.0F;
               var50 = 0.0F;
               if (var57 != null) {
                  switch(var57.g()) {
                  case 0:
                     double var52 = var57.e().size() > var33 ? var57.a(var57.e().get(var33)) : 0.0D;
                     var45 = var52;
                     var52 = var57.f().size() > var33 ? var57.a(var57.f().get(var33)) : 0.0D;
                     var47 = var52;
                     break;
                  case 1:
                     var45 = var57.c();
                     var47 = var45;
                     break;
                  case 2:
                     var45 = var57.c() * var34.v() / 100.0D;
                     var47 = -var45;
                  }

                  var49 = (float)var45 / (float)(var17 - var15) * (float)var2.f();
                  var50 = (float)var47 / (float)(var17 - var15) * (float)var2.f();
               }

               var57.a(var44, var49, var50);
               if (!var11.p()) {
                  var37 -= var41;
               } else {
                  var37 += var41;
               }

               com.aspose.cells.b.a.b.zo var58 = new com.aspose.cells.b.a.b.zo((float)var35, (float)var37);
               float var53 = 0.0F;
               float[] var54 = new float[]{var53};
               boolean var55 = a(var0, var58, var1, var34, var28, (int)a(var2), var54);
               var53 = var54[0];
               if (var55) {
                  Object[] var56 = new Object[]{var30, var33, var58, var12};
                  var34.a = var53;
                  com.aspose.cells.b.a.a.ze.a(var25, (Object)var56);
               }
            }
         } else {
            com.aspose.cells.b.a.a.ze.a(var31, (Object)null);
         }
      }

      var0.a(var7);
      return var25;
   }

   private static boolean a(zn var0, com.aspose.cells.b.a.b.zo var1, zbcp var2, zjd var3, double var4, int var6, float[] var7) {
      double var10 = var3.B();
      float var12 = (float)var2.Z() / 100.0F;
      int var13 = var2.ab();
      boolean var14 = var2.aa();
      if (var10 == 0.0D) {
         return false;
      } else {
         if (var14) {
            var10 = Math.abs(var10);
         } else if (var10 < 0.0D) {
            return false;
         }

         double var15 = 0.0D;
         double var8;
         if (var13 == 0) {
            var15 = 3.141592653589793D * Math.pow((double)var6, 2.0D) / var4;
            var8 = Math.sqrt(var10 * var15 / 3.141592653589793D);
         } else {
            var15 = (double)(2 * var6) / var4;
            var8 = var10 * var15 / 2.0D;
         }

         var8 *= (double)var12;
         com.aspose.cells.b.a.b.zq var17 = new com.aspose.cells.b.a.b.zq(var1.d() - (float)var8, var1.e() - (float)var8, 2.0F * (float)var8, 2.0F * (float)var8);
         var3.a(new com.aspose.cells.b.a.b.zq(var1.d(), var1.e(), (float)var8, (float)var8));
         if (var3.i().h() != 0) {
            if (var3.B() > 0.0D) {
               com.aspose.cells.b.a.b.zc var18 = zax.a(var3.i(), var17);

               try {
                  var0.a(var18, var17);
               } finally {
                  if (var18 != null) {
                     var18.f();
                  }

               }
            } else {
               com.aspose.cells.b.a.b.zu var34 = new com.aspose.cells.b.a.b.zu(Color.getWhite());

               try {
                  var0.a((com.aspose.cells.b.a.b.zc)var34, (com.aspose.cells.b.a.b.zq)var17);
               } finally {
                  if (var34 != null) {
                     var34.f();
                  }

               }
            }
         }

         com.aspose.cells.b.a.b.zm var35 = zama.a(var3.k());

         try {
            var0.a(var35, var17);
         } finally {
            if (var35 != null) {
               var35.r();
            }

         }

         var7[0] = var17.h();
         return true;
      }
   }

   private static double a(zbcr var0) {
      double var1 = 0.0D;

      for(int var3 = 0; var3 < var0.getCount(); ++var3) {
         zbcp var4 = var0.c(var3);
         boolean var5 = var4.aa();
         if (var4.m() == 12 || var4.m() == 13) {
            zjf var6 = var4.D();

            for(int var7 = 0; var7 < var6.getCount(); ++var7) {
               zjd var8 = var6.b(var7);
               if (var8 != null && !var8.a()) {
                  double var9 = var8.B();
                  if (var5) {
                     var9 = Math.abs(var9);
                  }

                  if (var1 < var9) {
                     var1 = var9;
                  }
               }
            }
         }
      }

      return var1;
   }

   static float a(com.aspose.cells.b.a.b.zp var0) {
      com.aspose.cells.b.a.b.zq var1 = new com.aspose.cells.b.a.b.zq((float)var0.c(), (float)var0.d(), (float)var0.e(), (float)var0.f());
      return a(var1);
   }

   static float a(com.aspose.cells.b.a.b.zq var0) {
      float var1 = var0.h() > var0.i() ? var0.i() : var0.h();
      return var1 / 8.0F;
   }

   static void a(zn var0, zbcr var1, com.aspose.cells.b.a.b.zp var2, int var3, boolean var4, boolean var5, boolean var6, boolean var7, boolean var8, boolean var9, boolean var10, boolean var11) throws Exception {
      zif var12 = var1.c(0).v();
      zbo var14 = var12.e();
      zbo var13 = var12.E();
      double var15 = var13.n() ? zbuk.e(var13.D()) : var13.D();
      double var17 = var13.n() ? zbuk.e(var13.z()) : var13.z();
      double var19 = var13.n() ? zbuk.e(var13.x()) : var13.x();
      double var21 = var14.n() ? zbuk.e(var14.D()) : var14.D();
      double var23 = var14.n() ? zbuk.e(var14.z()) : var14.z();
      double var25 = var14.n() ? zbuk.e(var14.x()) : var14.x();
      double var27 = (var23 - var21) / 2.0D;
      double var31 = (var17 - var15) / 2.0D;
      double[] var35 = new double[]{var27};
      double[] var36 = new double[]{var27};
      double[] var37 = new double[]{var31};
      double[] var38 = new double[]{var31};
      a(var1, var3, var35, var36, var37, var38);
      var27 = var35[0];
      double var29 = var36[0];
      var31 = var37[0];
      double var33 = var38[0];
      double var39 = (double)a(var2);
      double var41 = var39 * (var23 - var21) / (double)var2.e();
      double var43 = var39 * (var17 - var15) / (double)var2.f();
      ArrayList var45;
      boolean var46;
      double var47;
      double var49;
      double var51;
      if (!var13.n()) {
         var45 = var13.l;
         var46 = false;
         if (var11 && var33 - var43 <= var15) {
            var15 = zbuk.a(var15, var19);
            com.aspose.cells.b.a.a.ze.a(var45, (Object)var15);
            var43 = var39 * (var17 - var15) / (double)var2.f();
            var46 = true;
         }

         if (var10 && var31 + var43 >= var17) {
            var17 = zbuk.b(var17, var19);
            var45.add(0, var17);
            var43 = var39 * (var17 - var15) / (double)var2.f();
            var46 = true;
         }

         if (var8 && var13.l.size() > 11) {
            var47 = var19 * 0.35D;
            if (var33 - var43 - (Double)var45.get(var45.size() - 1) < var47 || (Double)var45.get(0) - (var31 + var43) < var47) {
               var46 = true;
               var19 *= 2.0D;
               var49 = (Double)var45.get(0);
               var51 = (Double)var45.get(var45.size() - 1);
               double var53 = var19;
               int var55 = zbuk.g(var19);
               var45.clear();
               int var56 = a(var10, var11, var49, var51);
               double var57;
               if (var56 == 1) {
                  for(var57 = var49; var57 > var51 || zbuk.a(var51, var57) < var53; var57 -= var53) {
                     var57 = zbuk.a(var57, var55);
                     com.aspose.cells.b.a.a.ze.a(var45, (Object)var57);
                  }
               } else if (var56 == 2) {
                  var57 = var51;

                  while(true) {
                     if (var57 > var49 && zbuk.a(var57, var49) >= var53) {
                        Collections.reverse(var45);
                        break;
                     }

                     var57 = zbuk.a(var57, var55);
                     com.aspose.cells.b.a.a.ze.a(var45, (Object)var57);
                     var57 += var53;
                  }
               } else {
                  var57 = 0.0D;

                  label235:
                  while(true) {
                     if (var57 > var49 && zbuk.a(var57, var49) >= var53) {
                        Collections.reverse(var45);
                        var57 = 0.0D;

                        while(true) {
                           if (var57 <= var51 && zbuk.a(var51, var57) >= var53) {
                              break label235;
                           }

                           var57 = zbuk.a(var57, var55);
                           com.aspose.cells.b.a.a.ze.a(var45, (Object)var57);
                           var57 -= var53;
                        }
                     }

                     var57 = zbuk.a(var57, var55);
                     com.aspose.cells.b.a.a.ze.a(var45, (Object)var57);
                     var57 += var53;
                  }
               }
            }
         }

         if (var46) {
            if (var45.size() >= 2) {
               if (var10) {
                  var13.d((Double)var45.get(0));
               }

               if (var11) {
                  var13.f((Double)var45.get(var45.size() - 1));
               }

               if (var8) {
                  var13.c(var19);
               }

               if (var9) {
                  var13.e(var19 / 5.0D);
               }
            }

            zbq.a(var0, var13, var1.c(0), false);
         }
      }

      if (!var14.n()) {
         var45 = var14.l;
         var46 = false;
         if (var7 && var29 - var41 <= var21) {
            var21 = zbuk.a(var21, var25);
            com.aspose.cells.b.a.a.ze.a(var45, (Object)var21);
            var41 = var39 * (var23 - var21) / (double)var2.e();
            var46 = true;
         }

         if (var6 && var27 + var41 >= var23) {
            var23 = zbuk.b(var23, var25);
            var45.add(0, var23);
            var41 = var39 * (var23 - var21) / (double)var2.e();
            var46 = true;
         }

         double var48;
         int var59;
         if (var7) {
            var59 = zbuk.g(var25);
            if ((var29 - var41 - (var27 + var41)) / (var21 - (var27 + var41)) > 0.9523809523809523D) {
               var48 = zbuk.a(var21 - var25, var59);
               com.aspose.cells.b.a.a.ze.a(var45, (Object)var48);
               var21 = var48;
               var41 = var39 * (var23 - var48) / (double)var2.e();
               var46 = true;
            }
         }

         if (var6) {
            var59 = zbuk.g(var25);
            if ((var27 + var41 - (var29 - var41)) / (var23 - (var29 - var41)) > 0.9523809523809523D) {
               var48 = zbuk.a(var23 + var25, var59);
               var45.add(0, var48);
               var41 = var39 * (var48 - var21) / (double)var2.e();
               var46 = true;
            }
         }

         if (var4 && var45.size() > 11) {
            var46 = true;
            var25 *= 2.0D;
            var47 = (Double)var45.get(0);
            var49 = (Double)var45.get(var45.size() - 1);
            var51 = var25;
            int var60 = zbuk.g(var25);
            var45.clear();
            int var54 = a(var6, var7, var47, var49);
            double var61;
            if (var54 == 1) {
               for(var61 = var47; var61 > var49 || zbuk.a(var49, var61) < var51; var61 -= var51) {
                  var61 = zbuk.a(var61, var60);
                  com.aspose.cells.b.a.a.ze.a(var45, (Object)var61);
               }
            } else if (var54 == 2) {
               var61 = var49;

               while(true) {
                  if (var61 > var47 && zbuk.a(var61, var47) >= var51) {
                     Collections.reverse(var45);
                     break;
                  }

                  var61 = zbuk.a(var61, var60);
                  com.aspose.cells.b.a.a.ze.a(var45, (Object)var61);
                  var61 += var51;
               }
            } else {
               var61 = 0.0D;

               label186:
               while(true) {
                  if (var61 > var47 && zbuk.a(var61, var47) >= var51) {
                     Collections.reverse(var45);
                     var61 = 0.0D;

                     while(true) {
                        if (var61 <= var49 && zbuk.a(var49, var61) >= var51) {
                           break label186;
                        }

                        var61 = zbuk.a(var61, var60);
                        com.aspose.cells.b.a.a.ze.a(var45, (Object)var61);
                        var61 -= var51;
                     }
                  }

                  var61 = zbuk.a(var61, var60);
                  com.aspose.cells.b.a.a.ze.a(var45, (Object)var61);
                  var61 += var51;
               }
            }
         }

         if (var46) {
            if (var45.size() >= 2) {
               if (var6) {
                  var14.d((Double)var45.get(0));
               }

               if (var7) {
                  var14.f((Double)var45.get(var45.size() - 1));
               }

               if (var4) {
                  var14.c(var25);
               }

               if (var5) {
                  var14.e(var25 / 5.0D);
               }
            }

            zbq.a(var0, var14, var2, var3, false, var1.c(0));
         }
      }

   }

   private static int a(boolean var0, boolean var1, double var2, double var4) {
      boolean var6 = true;
      byte var7;
      if (var0 && var1) {
         var7 = 3;
         if (var2 == 0.0D) {
            var7 = 2;
         }

         if (var4 == 0.0D) {
            var7 = 1;
         }
      } else if (!var0 && var1) {
         var7 = 1;
      } else if (var0 && !var1) {
         var7 = 2;
      } else {
         var7 = 2;
      }

      return var7;
   }

   private static void a(zbcr var0, int var1, double[] var2, double[] var3, double[] var4, double[] var5) {
      boolean var6 = false;
      boolean var7 = false;

      for(int var8 = 0; var8 < var0.getCount(); ++var8) {
         zjf var9 = var0.c(var8).D();

         for(int var10 = 0; var10 < var1; ++var10) {
            zjd var11 = var9.b(var10);
            if (var11 != null && !var11.b()) {
               if (!var6) {
                  var2[0] = var11.q();
                  var3[0] = var2[0];
                  var6 = true;
               } else {
                  if (var11.q() > var2[0]) {
                     var2[0] = var11.q();
                  }

                  if (var11.q() < var3[0]) {
                     var3[0] = var11.q();
                  }
               }
            }

            if (var11 != null && !var11.a()) {
               if (!var7) {
                  var4[0] = var11.v();
                  var5[0] = var4[0];
                  var7 = true;
               } else {
                  if (var11.v() > var4[0]) {
                     var4[0] = var11.v();
                  }

                  if (var11.v() < var5[0]) {
                     var5[0] = var11.v();
                  }
               }
            }
         }
      }

   }
}
